   var websocket = null;
   var msg =new Array();
   var iframeWin = null;
				     if ('WebSocket' in window) {
				         websocket = new WebSocket("ws://127.0.0.1:8080/websocket/socketServer.do");
				     } 
				     else if ('MozWebSocket' in window) {
				         websocket = new MozWebSocket("ws://127.0.0.1:8080/websocket/socketServer.do");
				     } 
				     else {
				         websocket = new SockJS("http://127.0.0.1:8080/sockjs/socketServer.do");
				     }
				     websocket.onopen = onOpen;
				     websocket.onmessage = onMessage;
				     websocket.onerror = onError;
				     websocket.onclose = onClose;
				               
				     function onOpen(openEvt) {
				         //alert(openEvt.Data);
				     }
				     
				     function onMessage(evt) {
				    	  var message = eval("("+evt.data+")");
							  
						     if(message.type=='1')
						     {  
						    	 msg.push(message); 
						    	 if(iframeWin!=null){
		    				    	 iframeWin.msgs=msg;
		    				    	 iframeWin.showMsg();
				    				 msg =new Array();
		    				    }
						     } else if(message.type=='3')
						     {  
						    	 alert(message.content);
						    	 
						     }   
				     }
				     function onError() {}
				     function onClose() {}
				     
				     function doSend(data) {
				         if (websocket.readyState == websocket.OPEN) {         
				        	 
						    	var To = data.to;
						    	var my = data.mine; 
							    var message = my.content;
							    var recount =To.id;// $('#receiver').val();
							 //   alert("{content:"+message+",type:1,receiver:"+recount+"}")
							    if(message=='')
							    {
							       return;
							    }else{
							    	message = message.replace(/\'/g, "\"");
							    }  
							    
							    websocket.send("{content:'"+message+"',type:'1',receiver:'"+recount+"'}");
							  /*  $.post("/send", {content:message,type:1,receiver:recount},
										   function(data){
										    //发送成功
							    }); */
				        	 
				            // var msg = "dddd";//document.getElementById("inputMsg").value;  
				           //调用后台handleTextMessage方法
				            // alert("发送成功!");  
				         } else {  
				             alert("连接失败!");  
				         }  
				     }
				   window.close=function() { websocket.onclose(); }


define(function(require, exports, module) {
	//var initState = seajs.data.vars.initState;
	 
	  
	
	 function basePage(){
		var _basePage=this;
		this.init=function(){
			var me=this; 
			me.basePage.init(); 
		};
		this.basePage={
			show:function(){
				var me=this;
				/*var stype =   me.getCookie('showType');
				 if(stype==1){
					 $(".page").addClass("theme-dark");
				 }else{
					 $(".page").removeClass("theme-dark");
				 }  */
			},
		    setCookie:function(c_name,value,expiredays){
				var exdate=new Date()
				exdate.setDate(exdate.getDate()+expiredays)
				document.cookie=c_name+ "=" +escape(value)+
				((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+";path=/"
			},
		    getCookie:function(c_name){
				if (document.cookie.length>0)
				  {
				  c_start=document.cookie.indexOf(c_name + "=")
				  if (c_start!=-1)
				    { 
				    c_start=c_start + c_name.length+1 
				    c_end=document.cookie.indexOf(";",c_start)
				    if (c_end==-1) c_end=document.cookie.length
				    return unescape(document.cookie.substring(c_start,c_end))
				    } 
				  }
				return ""
		    } ,
			init:function(){
				var me=this;
				var initObj ={};
				  
 
				var myApp = new Framework7();
				var $$ = Dom7;
				seajs.data.vars.myApp = myApp;
				seajs.data.vars.dom = $$;
				
				// Add view
				var mainView = myApp.addView('.view-main', {
				    dynamicNavbar: true,
				    domCache: true
				});
 
				
				
				//绑定聊天窗口
				layui.use(['layer'], function(layim){
				     var layer = layui.layer; 
				     $$(".msgim").on("click",function(){ 
				    	 layer.open({
				    		  type: 2,
				    		  title: false,
				    		  closeBtn: 0,
				    		  shadeClose:true,
				    		  anim:3,
				    		  area: ['100%', '100%'],
				    		  fixed: false, //不固定
				    		  maxmin: false,
				    		  content: '/user/im',
			    			  success: function(layero, index){
			    				    //var body = layer.getChildFrame('body', index);
			    				    iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
			    				    if(msg.length>0){
			    				    	 iframeWin.msgs=msg;
					    				 msg =new Array();
			    				    }
			    				     //alert(body.html()) //得到iframe页的body内容
			    				     
			    			  },
			    			  end :function(){
			    				  iframeWin =null;
			    				  msg =new Array();
			    			  }
				    		}); 
						 
					})
				})   
				
 
				seajs.data.vars.mainview = mainView;
 
			 
				//客户列表
				 myApp.onPageAfterAnimation('customerlist', function (page) {
						 require('customer/customer').init();
						 //mainView.showToolbar();
				 });
				 
				 //获取用户详细信息
				 myApp.onPageAfterAnimation('enterresume', function (page) {
					 //mainView.hideToolbar();
					 require('customer/enterresume').init();
				 });
              
				//获取企业详细信息
				 myApp.onPageAfterAnimation('entercustomer', function (page) {
					 //mainView.hideToolbar();
					 require('customer/entercustomer').init();
				 });
				 
				 //审批管理
				 myApp.onPageAfterAnimation('approvelist', function (page) { 
						 require('workmanage/approvelist').init();  
				 });  
			}
		}; 
	}
	 module.exports=new basePage(); 
});












 